﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CATLTempUpdate
{
    public partial class FormTcpService : Form
    {
        public FormTcpService()
        {
            InitializeComponent();
        }
        TcpReciveAndSend Readyte;
        
        private void FormTcpService_Load(object sender, EventArgs e)
        {
            string data = "3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:18:01:19:01:1a:01:19:01:1b:01:1c:01:0c:01:0e:01:13:01:17:01:18:01:18:01:17:01:13:01:17:01:0e:01:10:01:13:01:15:01:16:01:3e:fe:0c:01:19:01:17:01:0d:01:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:25:01:1e:01:28:01:24:01:35:01:22:01:50:01:37:01:3f:01:2f:01:5b:01:4a:01:55:01:45:01:29:01:60:01:6a:01:62:01:5f:01:4d:01:3e:fe:58:01:3b:01:49:01:62:01:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:26:01:26:01:22:01:24:01:25:01:16:01:2f:01:28:01:21:01:22:01:2e:01:26:01:2f:01:24:01:1c:01:2c:01:26:01:2d:01:2e:01:1b:01:3e:fe:18:01:22:01:20:01:22:01:29:01:ff:ff:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:05:01:07:01:03:01:03:01:00:01:0b:01:f3:00:f8:00:02:01:ff:00:03:01:01:01:04:01:0b:01:10:01:f4:00:f6:00:fc:00:fc:00:02:01:3e:fe:fe:00:0a:01:09:01:f0:00:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:fd:00:fe:00:ff:00:fd:00:01:01:fd:00:f6:00:fa:00:fa:00:fc:00:fc:00:fe:00:ff:00:fb:00:fa:00:f8:00:fa:00:fb:00:fb:00:fc:00:3e:fe:f6:00:fd:00:fe:00:f4:00:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:11:01:17:01:1e:01:1c:01:18:01:1a:01:fb:00:06:01:0a:01:0c:01:0f:01:13:01:10:01:08:01:16:01:01:01:04:01:0a:01:0c:01:0e:01:3e:fe:03:01:10:01:10:01:f6:00:43:01:ff:ff:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:00:01:01:01:06:01:08:01:0a:01:09:01:f1:00:f3:00:f4:00:f7:00:02:01:05:01:04:01:f8:00:02:01:f0:00:f4:00:f6:00:fc:00:00:01:3e:fe:f6:00:03:01:08:01:ee:00:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:4b:01:4b:01:53:01:4d:01:31:01:42:01:4a:01:5c:01:5f:01:4e:01:6a:01:5a:01:5f:01:64:01:40:01:70:01:79:01:7d:01:71:01:69:01:3e:fe:63:01:60:01:61:01:8a:01:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:17:01:13:01:15:01:15:01:11:01:15:01:19:01:1d:01:1d:01:18:01:0a:01:0e:01:0d:01:17:01:14:01:0b:01:13:01:0f:01:0d:01:0b:01:3e:fe:07:01:10:01:07:01:0a:01:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:11:01:10:01:0d:01:0d:01:0c:01:0e:01:17:01:16:01:19:01:14:01:0c:01:0c:01:0c:01:11:01:11:01:0e:01:0a:01:14:01:0e:01:0f:01:3e:fe:0c:01:16:01:0e:01:0d:01:30:01:ff:ff:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:18:01:0f:01:14:01:0d:01:06:01:0f:01:f7:00:06:01:0a:01:14:01:0c:01:0a:01:05:01:04:01:14:01:fd:00:07:01:09:01:0b:01:09:01:3e:fe:01:01:0d:01:0a:01:f8:00:2d:01:ff:ff:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:f7:00:fc:00:03:01:06:01:0c:01:06:01:ec:00:ee:00:f1:00:f6:00:fd:00:fc:00:00:01:f2:00:fd:00:ea:00:ee:00:f3:00:f6:00:f8:00:3e:fe:fd:00:fc:00:f0:00:e7:00:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:fa:00:f8:00:f6:00:fb:00:fc:00:f8:00:f5:00:f6:00:f7:00:f8:00:f8:00:fb:00:fa:00:f5:00:3e:fe:f5:00:f6:00:f8:00:f7:00:f6:00:3e:fe:f6:00:f8:00:f8:00:f7:00:32:01:ff:ff:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:0d:01:0d:01:0e:01:0f:01:0c:01:0a:01:09:01:0a:01:0d:01:0c:01:0c:01:09:01:08:01:09:01:10:01:0f:01:15:01:13:01:15:01:11:01:3e:fe:3e:fe:0e:01:08:01:0f:01:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:fb:00:fe:00:04:01:07:01:07:01:03:01:e7:00:d8:00:f0:00:f8:00:f8:00:fb:00:fc:00:f5:00:ff:00:e9:00:ed:00:f4:00:f6:00:f8:00:3e:fe:ee:00:fa:00:f7:00:e6:00:2c:01:ff:ff:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:3e:fe:0d:01:0b:01:0f:01:0d:01:05:01:0a:01:3e:fe:02:01:07:01:0d:01:0a:01:03:01:b7:00:0d:01:fa:00:ff:00:01:01:05:01:0a:01:0c:01:3e:fe:00:01:0c:01:04:01:f6:00:40:01:ff:ff";
            string tempdata = data;
            Byte[] headbyte = { 0xfe,0xdc ,0x10,0x00,0x01,0x00};

            for (int j = 0; j < headbyte.Length; j++)
            {
                TempCanData.Can1Temp.Add(headbyte[j]);
            }
            //添加测试数据
            for (int i = 0; i < tempdata.Length;)
            {
                string Temp = "";
                if (tempdata.Length > 0)
                {
                    if (tempdata.IndexOf(":")>0)
                    {
                        Temp = tempdata.Substring(0, tempdata.IndexOf(":"));
                        tempdata = tempdata.Substring(tempdata.IndexOf(":")+1);
                    }
                    else
                    {
                        Temp = tempdata;
                        tempdata = "";
                    }

                    TempCanData.Can1Temp.Add(Convert.ToByte(int.Parse(Temp, System.Globalization.NumberStyles.HexNumber)));
                }    
                
            }

            
            Readyte = new TcpReciveAndSend();
        }


       
    }
}
